﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Data.ConnectionUI;

namespace KeelKit.Core
{
    public class MySqlConnectionProperties : AdoDotNetConnectionProperties
    {
        // Methods
        public MySqlConnectionProperties()
            : base("MySql.Data.MySqlClient")
        {
            this.LocalReset();
        }

        private void LocalReset()
        {
            this["Unicode"] = true;
        }

        public override void Reset()
        {
            base.Reset();
            this.LocalReset();
        }

        protected override string ToTestString()
        {
            bool flag = (bool)base.ConnectionStringBuilder["Pooling"];
            bool flag2 = !base.ConnectionStringBuilder.ShouldSerialize("Pooling");
            base.ConnectionStringBuilder["Pooling"] = false;
            string connectionString = base.ConnectionStringBuilder.ConnectionString;
            base.ConnectionStringBuilder["Pooling"] = flag;
            if (flag2)
            {
                base.ConnectionStringBuilder.Remove("Pooling");
            }
            return connectionString;
        }

        // Properties
        public override bool IsComplete
        {
            get
            {
                if (!(base.ConnectionStringBuilder["Data Source"] is string) || ((base.ConnectionStringBuilder["Data Source"] as string).Length == 0))
                {
                    return false;
                }
                return (((bool)base.ConnectionStringBuilder["Integrated Security"]) || ((base.ConnectionStringBuilder["User ID"] is string) && ((base.ConnectionStringBuilder["User ID"] as string).Length != 0)));
            }
        }
    }

}
